package cn.xiehangs;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.InputEvent;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Button;
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable;
import com.badlogic.gdx.utils.viewport.StretchViewport;

public class test extends Game {
    Stage stage;
    SpriteBatch batch;
    Button.ButtonStyle style = new Button.ButtonStyle();

    @Override
    public void create() {
        Gdx.graphics.setWindowedMode(1024,1024);
        cn.xiehangs.聊天框 聊天框_1 = new cn.xiehangs.聊天框("我",0,0,300,512);

         stage = new Stage(new StretchViewport(1024, 1024));
        stage.addActor(聊天框_1.chat);
        stage.addActor(聊天框_1.send);
        qi_zi qi_zi = new qi_zi("hong", 1);
        stage.addActor(qi_zi);

        Gdx.input.setInputProcessor(stage);
        batch = new SpriteBatch();
        style.up = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("button_up.png"))));
        style.down = new TextureRegionDrawable(new TextureRegion(new Texture(Gdx.files.internal("button_down.png"))));
        Button button = new Button(style);
        button.setPosition(100, 100);
        button.setSize(100, 100);
        stage.addActor(button);
        button.addListener(new com.badlogic.gdx.scenes.scene2d.utils.ClickListener() {
            @Override
            public void clicked(InputEvent event, float x, float y) {
                聊天框_1.add("hello");
            }
        });

    }
    public void render() {
        Gdx.gl.glClear(Gdx.gl.GL_COLOR_BUFFER_BIT);
        Gdx.gl.glClearColor(0.6f, 0.6f, 0.6f, 1);
        batch.begin();
        batch.end();
        stage.act();
        stage.draw();
    }
}
